//
//  CXYHomeActiveItemCell.swift
//  诚叙缘
//
//  Created by sujeking on 17/3/22.
//  Copyright © 2017年 szw. All rights reserved.
//

import UIKit
import Masonry

class CXYHomeActiveItemCell: UITableViewCell {
    
    @IBOutlet weak var mScrollView: UIScrollView!
    
    let padding : CGFloat = 10.0 ;
    let margin : CGFloat = 15.0 ;
    
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        setupSubViews()
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    
    func setupSubViews() {
        mScrollView.contentSize = CGSize(width: 100000, height: 0)
        let screenWidth = UIScreen.main.bounds.width
        
        let marginLeft : CGFloat = 15
        let width : CGFloat = (screenWidth - 4 * marginLeft - 6 ) / 4

        
        for i in 0 ..< 200 {
            
            let nib = UINib.init(nibName: "CXYHomeActiveItemView", bundle: nil)
            let itemView = nib.instantiate(withOwner: self, options: nil).first as! CXYHomeActiveItemView
            
            itemView.translatesAutoresizingMaskIntoConstraints = false
            itemView.tag = i
            mScrollView.addSubview(itemView)
            
            itemView.mas_makeConstraints({ (make) in
                let left = CGFloat(i) * (width + self.padding) + self.margin
                _ = make?.top.equalTo()(self.mScrollView)?.with().offset()(10)
                _ = make?.left.equalTo()(left)
                _ = make?.width.equalTo()(width)
                _ = make?.height.equalTo()(self.mScrollView)?.with().offset()(-20)
            })
        }
        
    }
    
    
}
